<?php
include("include/config.inc.php");
if(!isset($_SESSION['s_activId']))
{
  $_SESSION['s_urlRedirectDir'] = $_SERVER['REQUEST_URI'];
  header("Location:index.php");
}
else
{
  $selFixRate = "SELECT rate 
                   FROM fixrate 
                  WHERE partyId = ".$_GET['partyId']." 
                    AND finalProcessId = ".$_GET['finalProcessId'];
  $selFixRateRes = mysql_query($selFixRate);
  if($row = mysql_fetch_array($selFixRateRes))
  {
    echo $row['rate'];
  }
  else
  {
    $selRate = "SELECT rate FROM fixrate WHERE partyId = ".$_GET['partyId']." AND finalProcessId = '0'";
    $selRateRes = mysql_query($selRate);
    if($frRow = mysql_fetch_array($selRateRes))
    {
    	echo $frRow['rate'];
    }
    else
    {
      $selFRate = "SELECT rate FROM fixrate WHERE partyId = '0' AND finalProcessId = ".$_GET['finalProcessId'];
      $selFRateRes = mysql_query($selFRate);
      if($FRRow = mysql_fetch_array($selFRateRes))
      {
      	echo $FRRow['rate'];
      }
      else
      {
	      $selFrate = "SELECT rate FROM fixrate WHERE partyId = '0' AND finalProcessId = '0'";
	      $selFrateRes = mysql_query($selFrate);
	      if($FRrow = mysql_fetch_array($selFrateRes))
	      {
      	  echo $FRrow['rate'];
      	}
      	else
      	{
      		echo 0;
      	}
      }
    }
  }
}
?>